
function keeperBoot(action)
{
    seajs.config({
        base: "/keeper/",
    });

    var rqs = [
        "~/twitter-bootstrap/3.1.1/css/bootstrap.min.css",
        "~/jquery/1.10.2/jquery.min.js",
        "~/lessui/master/js/BrowserDetect.js",
    ];
    seajs.use(rqs, function() {

        var browser = BrowserDetect.browser;
        var version = BrowserDetect.version;
        var OS      = BrowserDetect.OS;

        if (!((browser == 'Chrome' && version >= 20)
            || (browser == 'Firefox' && version >= 3.6)
            || (browser == 'Safari' && version >= 5.0 && OS == 'Mac'))) {

            keeperBodyLoader("error/browser");
            return;
        }

        rqs = [
            "~/lessui/master/css/lessui.min.css",
            "~/keeper/css/main.css?_="+ Math.random(),
            "~/twitter-bootstrap/3.1.1/js/bootstrap.min.js",
            "~/lessui/master/js/lessui.js",
        ];
        seajs.use(rqs, function() {
            if (action.length > 0) {
                keeperBodyLoader(action);
            }
        });
    });
}

function keeperAjax(obj, url)
{
    if (/\?/.test(url)) {
        url += "&_=";
    } else {
        url += "?_=";
    }
    url += Math.random();
    //console.log("req: keeper/"+ url);
    $.ajax({
        url     : "/keeper/"+ url,
        type    : "GET",
        timeout : 30000,
        success : function(rsp) {
            //console.log(rsp);
            $(obj).html(rsp);
        },
        error: function(xhr, textStatus, error) {

            if (xhr.status == 401) {
                //console.log("access denied");
                alert("Error: Access Denied");
                //keeperBodyLoader('user/login');
            } else {
                alert("Internal Server Error"); //+ xhr.responseText);
            }
        }
    });
}

function keeperBodyLoader(uri)
{
    keeperAjax("#body-content", uri);
}

function keeperComLoader(uri)
{
    keeperAjax("#com-content", uri);
}

function keeperWorkLoader(uri)
{
    keeperAjax("#work-content", uri);
}
